package org.chen.config;

import lombok.extern.slf4j.Slf4j;
import org.chen.client.CrawlerClient;
import org.chen.domain.dto.CrawlerStatisticsDTO;
import org.chen.domain.vo.CrawlerTaskVO;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 爬虫服务降级实现
 */
@Slf4j
@Component
public class CrawlerClientFallback implements CrawlerClient {
    
    @Override
    public CrawlerStatisticsDTO getStatistics() {
        log.error("调用爬虫服务统计接口失败，返回默认值");
        return new CrawlerStatisticsDTO();
    }
    
    @Override
    public List<CrawlerTaskVO> getRecentTasks(int limit) {
        log.error("调用爬虫服务最近任务接口失败，返回空列表");
        return Collections.emptyList();
    }
    
    @Override
    public Map<String, Integer> getTaskTrend(LocalDateTime startTime, LocalDateTime endTime) {
        log.error("调用爬虫服务趋势接口失败，返回空Map");
        return Collections.emptyMap();
    }
}